/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.DragonPokerServer.Thread.ServerRequest;

import org.Comunicator.Element;
import org.Comunicator.Global;
import org.Comunicator.Message;
import org.DragonPokerServer.Thread.ThreadUser;
import org.DragonPokerServer.dbclasses.Room;

/**
 *
 * @author alien
 */
public class CreateRoomRequest extends GenericServerRequest {

    @Override
    public void processRequest(Message message, ThreadUser user) {
        System.out.println("SERVER-CreateRoom");
        String name = (String) message.getParameters().get("Name");

        Room r2 = new Room();
        r2.setId(2);
        r2.setName(name);
        Global.rooms.add(r2);
        Message reply = new Message();
        reply.setAction("CreateRoomReply");
        reply.getReceiver().add(user.getUser().getUsername());
        reply.getParameters().add(new Element("Reply", true));
        Global.messages.addMessageToSend(reply);
    }

    @Override
    public boolean isToProcessing(Message message, ThreadUser user) {
        if ("CreateRoom".equals(message.getAction()) == true) {
            return true;
        }
        return false;
    }
}
